export default {
	state: {
		//登陆状态
		loginStatus: false,
		token: null,
		userInfo: {} //用户信息
	},
	getters: {

	},
	mutations: {
		initUser(state) {
			// 初始化用户信息
			let userInfo = uni.getStorageSync('userInfo')
			if (userInfo) {
				userInfo = JSON.parse(userInfo)
				state.userInfo = userInfo;
				state.loginStatus = true;
				state.token = userInfo.token;
			}
		},
		//登陆后保存信息
		login(state, userInfo) {
			state.userInfo = userInfo;
			state.loginStatus = true;
			state.token = userInfo.token;
			uni.setStorageSync('userInfo', JSON.stringify(userInfo))
		},
		//退出登陆
		loginOut(state) {
			state.loginStatus = false;
			state.userInfo = {};
			state.token = null;
			uni.removeStorageSync('userInfo')
			uni.removeStorageSync('token')
			console.log("退出成功");
		}

	},
	actions: {}
}
